<?php

/**
 * This is the model class for table "{{helpclass}}".
 *
 * The followings are the available columns in table '{{helpclass}}':
 * @property integer $id
 * @property string $text
 * @property string $val
 * @property string $ztype
 * @property integer $tmpi1
 * @property integer $tmpi2
 * @property integer $tmpi3
 * @property string $tmps1
 * @property string $tmps2
 * @property string $tmps3
 */
class Helpclass extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{helpclass}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('tmpi1, tmpi2, tmpi3', 'numerical', 'integerOnly'=>true),
			array('text, val, ztype', 'length', 'max'=>20),
			array('tmps1, tmps2, tmps3', 'length', 'max'=>50),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, text, val, ztype, tmpi1, tmpi2, tmpi3, tmps1, tmps2, tmps3', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'text' => '文本',
			'val' => '值',
			'ztype' => '分类',
			'tmpi1' => 'Tmpi1',
			'tmpi2' => 'Tmpi2',
			'tmpi3' => 'Tmpi3',
			'tmps1' => 'Tmps1',
			'tmps2' => 'Tmps2',
			'tmps3' => 'Tmps3',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('text',$this->text,true);
		$criteria->compare('val',$this->val,true);
		$criteria->compare('ztype',$this->ztype,true);
		$criteria->compare('tmpi1',$this->tmpi1);
		$criteria->compare('tmpi2',$this->tmpi2);
		$criteria->compare('tmpi3',$this->tmpi3);
		$criteria->compare('tmps1',$this->tmps1,true);
		$criteria->compare('tmps2',$this->tmps2,true);
		$criteria->compare('tmps3',$this->tmps3,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Helpclass the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
